package com.example.behaviordemo.adapter

import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.example.behaviordemo.model.Dynamic
import androidx.recyclerview.widget.RecyclerView.ViewHolder

import android.view.LayoutInflater
import android.widget.TextView
import com.example.behaviordemo.R
import com.example.behaviordemo.model.Article
import com.example.behaviordemo.model.SpecialColumn

/**
 * author : king_nina
 * e-mail : 13450414852@163.com
 * date   : 2021/12/2
 * desc   :
 */
class SpecialColumnAdapter : RecyclerView.Adapter<SpecialColumnAdapter.SpecialViewHolder> {

    private var specialColumns = mutableListOf<SpecialColumn>()

    constructor(datas: List<SpecialColumn>) {
        specialColumns.addAll(datas)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SpecialViewHolder {
        val view: View =
            LayoutInflater.from(parent.context).inflate(R.layout.item_special_column, parent, false)
        return SpecialViewHolder(view)
    }

    override fun onBindViewHolder(holder: SpecialViewHolder, position: Int) {
        val specialColumn = specialColumns[position]
        holder.tvFollow.text =
            "" + specialColumn.artCount + "篇文章  " + specialColumn.followCount + "人关注"
        holder.tvCategory.text = specialColumn.category
    }

    override fun getItemCount(): Int {
        return specialColumns.size
    }

    class SpecialViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        var tvFollow: TextView = itemView.findViewById(R.id.tvFollow)
        var tvCategory: TextView = itemView.findViewById(R.id.tvCategory)

    }
}